package com.chtw.edu.config;

import com.chtw.edu.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author chtw
 * @date 2020-10-11 18:31
 */
@Configuration
public class TokenInterceptorConfig implements WebMvcConfigurer {
    @Bean
    public WebMvcConfigurer  webMvcConfigurerAdapter(){
        return new WebMvcConfigurer() {
            //注册拦截器
            @Override
            public void addInterceptors(InterceptorRegistry registry) {
                registry.addInterceptor(new TokenInterceptor()).addPathPatterns("/**")
                        .excludePathPatterns("/user/authentication");
            }
        };
    }

}
